package com.atguigu.flink.function;

import com.atguigu.flink.wordcount.Demo5_POJO;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.util.Collector;

/**
 * Created by Smexy on 2023/2/23
 */
public class MyWordCountFlatMapFunction implements FlatMapFunction<String, Demo5_POJO.WordCount>
{
    @Override
    public void flatMap(String line, Collector<Demo5_POJO.WordCount> out) throws Exception {
        String[] words = line.split(" ");
        for (String word : words) {
            out.collect(new Demo5_POJO.WordCount(word,1));
        }
    }
}
